public class problem40 {
    public static void main(String[] args) {
        Integer power = 6;
        StringBuilder stringBuilder = new StringBuilder();
        Integer counter = 1;
        do {
            System.out.println(stringBuilder.length());
            stringBuilder.append(counter.toString());
            counter++;
        } while(stringBuilder.length() < ((Double)Math.pow(10, 6)).intValue());

        String string = stringBuilder.toString();
        Integer product = 1;
        for(int i = 0; i < power; i++) {
            Integer position = ((Double)Math.pow(10, i)).intValue();
            Integer value = Integer.valueOf(string.substring(position - 1, position));
            product *= value;
        }
        System.out.println(product);
    }
}
